package com.syeet.gulimall.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xhl
 * @date 2022/5/23
 */
@Configuration
public class ElasticSearchConfig {

    public static final RequestOptions COMOM_OPTIONS;
    static {
        //请求设置
        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
        COMOM_OPTIONS = builder.build();
    }

    @Bean
    public RestHighLevelClient restHighLevelClient(){
        return new RestHighLevelClient(RestClient.builder(
                HttpHost.create("http://192.168.5.155:9200")
        ));
    }
}
